from collections import deque


def get_layers(root):
    q, ans = deque(), list()
    q.append(root)
    while q:
        tmp, len_q = list(), len(q)
        for _ in range(len_q):
            node = q.popleft()
            tmp.append(node)
            if node.left:
                q.append(node.left)
            if node.right:
                q.append(node.right)
        ans.append(tmp)
    return ans

from instance import Tree1
from entity import TreeNode
ans = get_layers(Tree1.tree1)
print(ans)

one_tree = TreeNode(6)
ans2 = get_layers(one_tree)
print(ans2)
